﻿namespace Digitalmes.Application.Sys.Dicts.Queries;

/// <summary>
/// 字典分页查询命令。
/// </summary>
public record GetDictWithPagedQuery : PagedQuery, IRequest<IResult<PagedList<SysDictDto>>>;

internal sealed class GetDictWithPagedQueryHandler(IRepository<SysDict> repo) : IRequestHandler<GetDictWithPagedQuery, IResult<PagedList<SysDictDto>>>
{
    public async Task<IResult<PagedList<SysDictDto>>> Handle(GetDictWithPagedQuery request, CancellationToken cancellationToken)
    {
        var ret = await repo.GetPagedListAsync(null, request.PageNumber, request.PageSize, cancellationToken);
        return Result.From(ret.Adapt<PagedList<SysDictDto>>());
    }
}
